<?php

/**
 * Description of network_model
 *
 * @author dian
 */
class Network_Model extends MY_Model {

    function __construct() {
        parent::__construct();
    }

    function get_board($alias, $is_starter = true) {
        $this->db->select("*");
        if ($this->is_expert($alias)) {
            $this->db->from("board_member_expert");
        } else {
            $this->db->from("board_member_starter");
        }
        $this->db->where(array("id_member" => $alias));
        return $this->db->get()->row();
    }
    
    function is_expert($alias) {
        $is_expert = $this->db->query("select id_member from board_member_expert where id_member=?", array($alias))->row()->id_member;
        
        if ($is_expert) {
            return true;
        } else {
            return false;
        }
    }

    function get_downline($id_member) {
        $this->db->select("*");
        $this->db->from("member");
        $this->db->where(array("upline" => $id_member));
        return $this->db->get();
    }

}
